part of '../page.dart';

class _MobileNumberPaymentAdditionActionBlock extends StatelessWidget with ScreenUtilMixin {
  const _MobileNumberPaymentAdditionActionBlock({
    required this.markedUpTitle,
  });

  final String markedUpTitle;

  double get _scaleFactor => logWidthScaleFactor;

  @override
  Widget build(BuildContext context) {
    final parts = markedUpTitle.split('#');
    final partTextSpans = <TextSpan>[];

    for (var i = 0; i < parts.length; i++) {
      late final TextSpan textSpan;
      if (i.isEven) {
        textSpan = TextSpan(text: parts[i]);
      } else {
        textSpan = TextSpan(
          text: parts[i],
          style: IosPaymentBySimCardPageTheme.of(context)
              .textTheme
              .mobileNumberPaymentAdditionBoldAction,
        );
      }
      partTextSpans.add(textSpan);
    }

    return Row(
      children: [
        SizedBox(
          width: 5 * _scaleFactor,
        ),
        Icon(
          Icons.star,
          size: 20 * _scaleFactor,
          color: CoreTheme.of(context).primaryColor,
        ),
        SizedBox(
          width: 16 * _scaleFactor,
        ),
        Expanded(
          child: Text.rich(
            TextSpan(
              style: IosPaymentBySimCardPageTheme.of(context)
                  .textTheme
                  .mobileNumberPaymentAdditionAction,
              children: partTextSpans,
            ),
            textAlign: TextAlign.start,
            textScaleFactor: _scaleFactor,
          ),
        ),
      ],
    );
  }
}
